<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/iron-icon/iron-icon.html">
<dom-module id="app-check">
    <template>
        <style>
        :host {
            display: inline-block;
            min-width: 36px;
        }

        :host([selected]) .check {
            transform: rotate3d(0, 1, 0, 180deg);
        }

        :host([selected]) iron-icon {
            transform: rotate3d(0, 1, 0, -180deg) scale(1);
            opacity: 1;
        }

        :host([selected]) .unchecked,
        :host([selected])::slotted(iron-icon) {
            opacity: 0;
        }

        .check {
            border-radius: 50%;
            width: 36px;
            height: 36px;
            transition: transform 350ms ease-in-out;
            background-color: rgba(158, 158, 158, 0.13);
            color: white;
            will-change: transform;
            cursor: pointer;
            box-sizing: border-box;
        }

        .unchecked {
            border-radius: inherit;
            width: 100%;
            height: 100%;
            transition: opacity 200ms ease-in-out 100ms;
            will-change: opacity;
            text-transform: uppercase;
        }

        iron-icon {
            transition: transform 300ms ease-in-out 100ms;
            will-change: opacity;
            transform: rotate3d(0, 1, 0, -180deg) scale(0);
            position: absolute !important;
            top: 15%;
            left: 15%;
            opacity: 0;
        }

        :host([disabled]) {
            display: inline-block;
            opacity: 0;
        }
        </style>
        <div class="check">
            <span class="unchecked layout horizontal center-center">
                <slot></slot>
            </span>
            <iron-icon icon="check"></iron-icon>
        </div>
    </template>
</dom-module>
<script>
Polymer({
    is: 'app-check',

    properties: {
        item: {
            type: Object
        },
        selected: {
            type: Boolean,
            value: false,
            reflectToAttribute: true
        }
    }

});
</script>
</dom-module>
